<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<%@ page import="com.msmall.community.space.util.SpaceConstants" language="java"%>
<c:set var="UNLOCK_STATUS" value="<%=ConstantDB.UNLOCK_STATUS%>"></c:set>
<c:set var="LOCK_STATUS" value="<%=ConstantDB.LOCK_STATUS%>"></c:set>
<c:set var="SPACE_WIDGET_PART_DIARY" value="<%=SpaceConstants.SPACE_WIDGET_PART_DIARY%>"></c:set>

<script type="text/javascript" charset="utf-8" src="${ctx}/editor/kindeditor-min.js"></script>

<div class="spaw730nav">
	<p class="sHB00 fl" onclick="spaceIndexNav(<c:out value='${SPACE_WIDGET_PART_DIARY}'/>)">
		我的日记
	</p>
	>>
	<a class="lH00" id="a_space_album" href="#">写日记</a>
</div>
<div class="spalistphoto">
	<form id="f_new_diary" action="<c:url value='/diary/save.do'/>" method="POST" >
		<input id="diary_id" name="diary.diaryid" value="${diary.diaryid}" type="hidden"/>
		
		标题:
		<input id="diary_title" name="diary.title" value="${diary.title}" size="20" class="input"/>
		<br/>
		内容：
		<br/>
		<div id="div_diary_error" class="div_diary_error" style="display:none"></div>
		<textarea id="diary_content" name="diary.content" style="width:700px;height:400px">
		</textarea>
		<br/>
		<button class="btn1" type="button" name="submitDiary" onclick="javascript:submitDiaryForm();">保存</button>
	</form>
</div>
<div class="pagediv martop10 tc clear">
</div>
<script>
KE.show({
	id : 'diary_content',
	imageUploadJson : ctx+'/h/keditor.do',
	fileManagerJson : ctx + '/editor/jsp/file_manager_json.jsp',
	allowFileManager : true,
	afterCreate : function(id) {
		alert("x");
		KE.event.ctrl(document, 13, function() {
			KE.util.setData(id);
			document.forms['diary_content'].submit();
		});
		KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
			KE.util.setData(id);
			document.forms['diary_content'].submit();
		});
	}
});
function submitDiaryForm(){
	$("#div_diary_error").html();
	$("#div_diary_error").css("display", "none");
	$.ajax({
		type : "POST",
		url : ctx + "/diary/save.do",
		data : $("#f_new_diary").serialize(),
		dataType:"xml", 
		timeout:20000,
		success : function(data){
			if($(data).find('result').text().toUpperCase().indexOf("TRUE") >= 0){
				spaceDiaryView($(data).find('content').text());
			}else{
				$("#div_diary_error").html($(data).find('content').text());
				$("#div_diary_error").css("display", "block");
			}
		},
		error: function(){
		}
	});
}
</script>